import { _decorator, Component, Label } from 'cc';
const { ccclass, inspector, property } = _decorator;

import { VMLabel, VMNode, mvvm, VMButtonClick } from "../../framework/vm/VMDecorator";

import * as cc from "cc";
import { VMTween } from '../../framework/vm/VMTransitionValue';
import { userData } from '../../game/storage/UserData';
import { VMEntity } from '../../framework/vm/VMEntity';
import { DemoVMSceneBase } from './DemoVMSceneBase';

@ccclass('DemoVMLabel')
// @mvvm()
export default class DemoVMLabel extends DemoVMSceneBase implements IMVVM{
    _vmTag: string;
    _vmEntitys: VMEntity[];

    // @VMLabel({
    //     watchPath: 'userdata.level', vmTween: VMTween(), formator(opts) {
    //         return Math.round(opts.newValue);
    //     }
    // })
    @property(Label)
    levelLabel: cc.Label = null;

    // @VMLabel({
    //     watchPath: ['userdata.level', 'userdata.mhp'], vmTween: VMTween(), templateMode: true, formator(opts) {
    //         return Math.round(opts.newValue);
    //     }
    // })
    @property(cc.Label)
    levelMaxLabel: cc.Label = null;

    // @VMButton({
    //     watchPath: 'userdata.level', min: 0, max: 999, operation: (param) => {
    //         return param.currentValue - 100;
    //     }
    // })
    @property(cc.Button)
    btnMulLevel: cc.Button = null;


    // @VMButton({
    //     watchPath: 'userdata.level', min: 0, max: 999, operation: (param) => {
    //         return param.currentValue + 100;
    //     }
    // })
    @property(cc.Button)
    btnAddLevel: cc.Button = null;


    onLoad() {
    }
    

    start() {
        super.start();
        this.schedule(() => {
            userData.mhp += 10;
        }, 2, 3)
    }
    onEditBoxEnded(event) {
        console.log('DemoVMButton-> ', event.string);

        let num = parseInt(event.string);
        if (isNaN(num)) {
            return;
        }
        userData.level = num;

    }
    // // update (dt) {}
}
